package com.amc.entity;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.Table;

import org.hibernate.annotations.GenericGenerator;

@Entity
@Table(name = "AMC_ORDER_FOOD")
public class OrderFood implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	@GeneratedValue(generator = "PK_ORDER_UUID")
	@GenericGenerator(name = "PK_ORDER_UUID", strategy = "uuid")
	@Column(name = "order_food_id")
	private String orderFoodId;

	@Column(name = "food_id")
	private String foodId;

	@Column(name = "order_food_name")
	private String orderFoodName;

	@Column(name = "order_food_price")
	private double orderFoodPrice;

	@Column(name = "order_food_pic")
	private String orderFoodPic;

	@Column(name = "order_food_count")
	private long orderFoodCount;

	@OneToOne(targetEntity = FoodType.class)
	@JoinColumn(name = "type_id")
	private FoodType foodType;

	@OneToOne(targetEntity = Merchant.class)
	@JoinColumn(name = "merchant_id")
	private Merchant foodMerchant;

	public OrderFood(String orderFoodId, String foodId, String orderFoodName,
			double orderFoodPrice, String orderFoodPic, long orderFoodCount,
			FoodType foodType, Merchant foodMerchant) {
		super();
		this.orderFoodId = orderFoodId;
		this.foodId = foodId;
		this.orderFoodName = orderFoodName;
		this.orderFoodPrice = orderFoodPrice;
		this.orderFoodPic = orderFoodPic;
		this.orderFoodCount = orderFoodCount;
		this.foodType = foodType;
		this.foodMerchant = foodMerchant;
	}

	public OrderFood() {
		super();
	}

	public String getOrderFoodId() {
		return orderFoodId;
	}

	public void setOrderFoodId(String orderFoodId) {
		this.orderFoodId = orderFoodId;
	}

	public String getFoodId() {
		return foodId;
	}

	public void setFoodId(String foodId) {
		this.foodId = foodId;
	}

	public String getOrderFoodName() {
		return orderFoodName;
	}

	public void setOrderFoodName(String orderFoodName) {
		this.orderFoodName = orderFoodName;
	}

	public double getOrderFoodPrice() {
		return orderFoodPrice;
	}

	public void setOrderFoodPrice(double orderFoodPrice) {
		this.orderFoodPrice = orderFoodPrice;
	}

	public String getOrderFoodPic() {
		return orderFoodPic;
	}

	public void setOrderFoodPic(String orderFoodPic) {
		this.orderFoodPic = orderFoodPic;
	}

	public long getOrderFoodCount() {
		return orderFoodCount;
	}

	public void setOrderFoodCount(long orderFoodCount) {
		this.orderFoodCount = orderFoodCount;
	}

	public FoodType getFoodType() {
		return foodType;
	}

	public void setFoodType(FoodType foodType) {
		this.foodType = foodType;
	}

	public Merchant getFoodMerchant() {
		return foodMerchant;
	}

	public void setFoodMerchant(Merchant foodMerchant) {
		this.foodMerchant = foodMerchant;
	}

	public static long getSerialversionuid() {
		return serialVersionUID;
	}

	@Override
	public String toString() {
		return "OrderFood [orderFoodId=" + orderFoodId + ", foodId=" + foodId
				+ ", orderFoodName=" + orderFoodName + ", orderFoodPrice="
				+ orderFoodPrice + ", orderFoodPic=" + orderFoodPic
				+ ", orderFoodCount=" + orderFoodCount + ", foodType="
				+ foodType + ", foodMerchant=" + foodMerchant + "]";
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((foodId == null) ? 0 : foodId.hashCode());
		result = prime * result
				+ ((foodMerchant == null) ? 0 : foodMerchant.hashCode());
		result = prime * result
				+ ((foodType == null) ? 0 : foodType.hashCode());
		result = prime * result
				+ (int) (orderFoodCount ^ (orderFoodCount >>> 32));
		result = prime * result
				+ ((orderFoodId == null) ? 0 : orderFoodId.hashCode());
		result = prime * result
				+ ((orderFoodName == null) ? 0 : orderFoodName.hashCode());
		result = prime * result
				+ ((orderFoodPic == null) ? 0 : orderFoodPic.hashCode());
		long temp;
		temp = Double.doubleToLongBits(orderFoodPrice);
		result = prime * result + (int) (temp ^ (temp >>> 32));
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		OrderFood other = (OrderFood) obj;
		if (foodId == null) {
			if (other.foodId != null)
				return false;
		} else if (!foodId.equals(other.foodId))
			return false;
		if (foodMerchant == null) {
			if (other.foodMerchant != null)
				return false;
		} else if (!foodMerchant.equals(other.foodMerchant))
			return false;
		if (foodType == null) {
			if (other.foodType != null)
				return false;
		} else if (!foodType.equals(other.foodType))
			return false;
		if (orderFoodCount != other.orderFoodCount)
			return false;
		if (orderFoodId == null) {
			if (other.orderFoodId != null)
				return false;
		} else if (!orderFoodId.equals(other.orderFoodId))
			return false;
		if (orderFoodName == null) {
			if (other.orderFoodName != null)
				return false;
		} else if (!orderFoodName.equals(other.orderFoodName))
			return false;
		if (orderFoodPic == null) {
			if (other.orderFoodPic != null)
				return false;
		} else if (!orderFoodPic.equals(other.orderFoodPic))
			return false;
		if (Double.doubleToLongBits(orderFoodPrice) != Double
				.doubleToLongBits(other.orderFoodPrice))
			return false;
		return true;
	}

	
}
